package controller

import (
	"fmt"
)

//var user = os.Getenv("user")

func init() {
	//if user == "" {
	//	panic("no value for $USER")
	//}
}

// 返回a、b中最大值.
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func MyFunc1() {
	x := 3
	y := 4
	z := 5

	maxXy := max(x, y) //调用函数max(x, y)
	maxXz := max(x, z) //调用函数max(x, z)

	fmt.Printf("max(%d, %d) = %d\n", x, y, maxXy)
	fmt.Printf("max(%d, %d) = %d\n", x, z, maxXz)
	fmt.Printf("max(%d, %d) = %d\n", y, z, max(y, z)) // 也可在这直接调用它
}

// SumAndProduct 返回 A+B 和 A*B
func SumAndProduct(A, B int) (int, int) {
	return A + B, A * B
}

func MyFunc2() {
	x := 3
	y := 4

	xPLUSy, xTIMESy := SumAndProduct(x, y)

	fmt.Printf("%d + %d = %d\n", x, y, xPLUSy)
	fmt.Printf("%d * %d = %d\n", x, y, xTIMESy)
}

func add(a int) int {
	a = a + 1
	return a
}

func TestX() {

	x := 3
	x1 := add(x)
	fmt.Println(x)
	fmt.Println(x1)
}

func add1(a *int) int {
	*a = *a + 1
	return *a
}
